import supplierApi from "@/api/declaration/erp/supplierApi"
import httpRequest from "@/config/axios/httpRequest"
import { SupplierModel } from "@/models/erp/SupplierModel"


// ERP 供应商 API
export const SupplierApi = {
  // 查询供应商分页
  getSupplierPage: async (params: any) => {
    return await httpRequest.get<SupplierModel[]>(supplierApi.GetSupplierPage, params)
  },

  // 获得供应商精简列表
  getSupplierSimpleList: async () => {
    return await httpRequest.get<SupplierModel[]>(supplierApi.GetSupplierSimpleList)
  },

  // 查询供应商详情
  getSupplier: async (id: number) => {
    return await httpRequest.get<SupplierModel>(supplierApi.GetSupplier, { params: { id} })
  },

  // 新增供应商
  createSupplier: async (data: SupplierModel) => {
    return await httpRequest.post(supplierApi.CreateSupplier, data)
  },

  // 修改供应商
  updateSupplier: async (data: SupplierModel) => {
    return await httpRequest.put(supplierApi.UpdateSupplier, data)
  },

  // 删除供应商
  deleteSupplier: async (id: number) => {
    return await httpRequest.delete(supplierApi.DeleteSupplier, { params: { id } })
  },

  // 导出供应商 Excel
  exportSupplier: async (params) => {
    return await httpRequest.download(supplierApi.ExportSupplier, params)
  }
}
